package routers

import (
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/context"
)

func init() {
	beego.InsertFilter("/user/*", beego.BeforeExec, LoginFunc)
	beego.InsertFilter("/admin/*", beego.BeforeExec, AdminFunc)
	User()
	Goods()
	Admin()
}

var LoginFunc = func(ctx *context.Context) {
	userName := ctx.Input.Session("userName")
	if userName == nil {
		ctx.Redirect(302, "/login")
		return
	}
}

func AdminFunc(ctx *context.Context) {
	user := ctx.Input.Session("adminName")
	if user == nil {
		ctx.Redirect(302, "/Admin/login")
		return
	}
}
